package com.xlx.openLink.controller;

import com.xlx.openLink.base.BaseDateMessage;
import com.xlx.openLink.base.ThreadRunTimeExcption;
import com.xlx.openLink.enums.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import net.percederberg.mibble.MibLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author seven
 * @create 2020-12-25 11:02
 **/
@Controller
@RequestMapping("/mib")
@Slf4j
public class MibController {

    @Autowired
    private MibLoader MibLoader;

    /**
     * 添加mib文件
     * @return
     */
    @ResponseBody
    @PostMapping("/addmib")
    public BaseDateMessage update() {
        BaseDateMessage baseDateMessage = new BaseDateMessage();
        try {
            baseDateMessage.buildSuccess(ResultCodeEnum.SUCCESS);
            baseDateMessage.setMsg("更新成功");
        } catch (ThreadRunTimeExcption excption) {
            baseDateMessage.buildSuccess(excption.getResultCodeEnum());
        } catch (Exception e) {
            log.info(e.getMessage());
            baseDateMessage.buildFail(ResultCodeEnum.FAIL);
            baseDateMessage.setMsg("更新失败");
        }
        return baseDateMessage;
    }

}
